package com.jxt.myapp.domain.jqgrid;

public class Criterion  {
	public static enum CriterionType {
		EQUAL, LIKE, COMPARE, NOT_LIKE
	}

	public static enum CompareType {
		GT, GTE, LT, LTE, EQ, NE
	}

	private CriterionType criterionType;
	private String field;
	private Object value;
	private String groupOp;

	public static class CompareCriterion extends Criterion {
		private CompareType compareType;

		public CompareType getCompareType() {
			return compareType;
		}

		public void setCompareType(CompareType compareType) {
			this.compareType = compareType;
		}
	}

	public static class LikeCriterion extends Criterion {
	}

	public static class NotLikeCriterion extends Criterion {
	}

	public static class EqualCriterion extends Criterion {
	}

	public static Criterion getCompareCriterion(String groupOp,
			CompareType compareType, String field, Object value) {
		CompareCriterion compareCriterion = new CompareCriterion();
		compareCriterion.setGroupOp(groupOp);
		compareCriterion.setCriterionType(CriterionType.COMPARE);
		compareCriterion.setCompareType(compareType);
		compareCriterion.setField(field);
		compareCriterion.setValue(value);
		return compareCriterion;
	}

	public static Criterion getLikeCriterion(String groupOp, String field,
			Object value) {
		LikeCriterion likeCriterion = new LikeCriterion();
		likeCriterion.setGroupOp(groupOp);
		likeCriterion.setCriterionType(CriterionType.LIKE);
		likeCriterion.setField(field);
		likeCriterion.setValue(value);
		return likeCriterion;
	}

	public static Criterion getNotLikeCriterion(String groupOp, String field,
			Object value) {
		NotLikeCriterion notLikeCriterion = new NotLikeCriterion();
		notLikeCriterion.setGroupOp(groupOp);
		notLikeCriterion.setCriterionType(CriterionType.NOT_LIKE);
		notLikeCriterion.setField(field);
		notLikeCriterion.setValue(value);
		return notLikeCriterion;
	}

	public static Criterion getEqualCriterion(String groupOp, String field,
			Object value) {
		EqualCriterion equalCriterion = new EqualCriterion();
		equalCriterion.setGroupOp(groupOp);
		equalCriterion.setCriterionType(CriterionType.EQUAL);
		equalCriterion.setField(field);
		equalCriterion.setValue(value);
		return equalCriterion;
	}

	public CriterionType getCriterionType() {
		return criterionType;
	}

	public void setCriterionType(CriterionType criterionType) {
		this.criterionType = criterionType;
	}

	public String getField() {
		return field;
	}

	public void setField(String field) {
		this.field = field;
	}

	public Object getValue() {
		return value;
	}

	public void setValue(Object value) {
		this.value = value;
	}

	public String getGroupOp() {
		return groupOp;
	}

	public void setGroupOp(String groupOp) {
		this.groupOp = groupOp;
	}

}
